home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / scope / 126-150 / scopedisk146 / curses / curses.h < prev    next >
C/C++ Source or Header  |  1995-03-19  |  7KB  |  193 lines

  1. /*
  2.  *
  3.  *    Author    : Simon J Raybould.    (sie@fulcrum.bt.co.uk).
  4.  *
  5.  *    Date    : 8th April 1990.
  6.  *
  7.  *    Desc    : Header file for my AMIGA CURSES package.
  8.  *          This should be included instead of stdio.h, this will
  9.  *          stdio.h for you.
  10.  *          This file is Public Domain but please leave the name
  11.  *          of the author intact.
  12.  *
  13.  */
  14.  
  15.  
  16. #ifndef stdin    /* May be a better way to do this !! */
  17. #include <stdio.h>
  18. #endif /* stdin */
  19.  
  20. #define LINES    (24)
  21. #define COLS    (80)
  22.  
  23. #ifndef TRUE
  24. #define TRUE    (1)
  25. #define FALSE    (0)
  26. #endif /* TRUE */
  27.  
  28. #define ERR    (-1)
  29. #define OK    (0)
  30.  
  31.  
  32. /*
  33.  *    Macros
  34.  */
  35.  
  36. #define addch(c)            waddch(stdscr, c)
  37. #define addstr(str)            waddstr(stdscr, str)
  38. #define attrset(attr)            wattrset(stdscr, attr)
  39. #define attron(attr)            wattron(stdscr, attr)
  40. #define attroff(attr)            wattroff(stdscr, attr)
  41. #define clear()                wclear(stdscr)
  42. #define clrtoeol()            wclrtoeol(stdscr)
  43. #define clrtobot()            wclrtobot(stdscr)
  44. #define delch()                wdelch(stdscr)
  45. #define deleteln()            wdeleteln(stdscr)
  46. #define erase()                werase(stdscr)
  47. #define inch()                winch(stdscr)
  48. #define insch(c)            winsch(stdscr, c)
  49. #define insertln()            winsertln(stdscr)
  50. #define getch()                wgetch(stdscr)
  51. #define getstr(ptr)            wgetstr(stdscr, ptr)
  52. #define getyx(window, y, x)        (y = window->_cury + window->_begy, \
  53.                     x = window->_curx + window->_begx)
  54. #define move(line, col)            wmove(stdscr, line, col)
  55. #define mvdelch(y, x)            (move(y, x), delch())
  56. #define mvwdelch(win, y, x)        (move(y, x), wdelch(win))
  57. #define mvgetch(y, x)            (move(y, x), getch())
  58. #define mvwgetch(win, y, x)        (move(y, x), wgetch(win))
  59. #define mvgetstr(y, x, ptr)        (move(y, x), getstr(ptr))
  60. #define mvwgetstr(win, y, x, ptr)    (move(y, x), wgetstr(win, ptr))
  61. #define mvinsch(y, x, c)        (move(y, x), insch(c))
  62. #define mvwinsch(win, y, x, c)        (move(y, x), winsch(win, c))
  63. #define mvinch(y, x)            (move(y, x), inch())
  64. #define mvwinch(win, y, x)        (move(y, x), winch(win))
  65. #define mvaddch(y, x, c)        (move(y, x), addch(c))
  66. #define mvwaddch(win, y, x, c)        (move(y, x), waddch(win, c))
  67. #define mvaddstr(y, x, str)        (move(y, x), addstr(str))
  68. #define mvwaddstr(win, y, x, str)    (move(y, x), waddstr(win, str))
  69. #define refresh()            wrefresh(stdscr)
  70. #define setscrreg(top, bottom)        wsetscrreg(stdscr, top, bottom)
  71. #define standend()            wstandend(stdscr)
  72. #define standout()            wstandout(stdscr)
  73.  
  74. /*
  75.  *    NON STANDARD MACROS
  76.  */
  77.  
  78. #define pencolour(n)    wpencolour(stdscr, n)
  79.  
  80. /*
  81.  *    Colours
  82.  */
  83.  
  84. #define    COLOR_BLACK    (0)    /* Black */
  85. #define    COLOR_WHITE    (1)    /* White */
  86. #define    COLOR_YELLOW    (2)    /* Background Blue */
  87. #define    COLOR_ORANGE    (3)    /* Orange */
  88. #define COLOR_BLUE    (4)    /* Blue */
  89. #define COLOR_MAGENTA    (5)    /* Magenta */
  90. #define    COLOR_CYAN    (6)    /* Cyan */
  91. #define COLOR_PWHITE    (7)    /* Paper White */
  92. #define COLOR_BROWN    (8)    /* Brown */
  93. #define    COLOR_RED    (9)    /* Red */
  94. #define COLOR_LGREEN    (10)    /* Light Green */
  95. #define COLOR_TAN    (11)    /* Well err Tan really */
  96. #define COLOR_BBLUE    (12)    /* Different to BLUE */
  97. #define COLOR_PURPLE    (13)    /* Pomegranate colour */
  98. #define COLOR_GREEN    (14)    /* The Bla Bla Bla of home e.t.c. */
  99. #define COLOR_GREY    (15)    /* Dead giveaway that one */
  100.  
  101.  
  102. /*
  103.  *    Video Attributes.
  104.  */
  105.  
  106. #define    A_NORMAL    0000000
  107. #define    A_STANDOUT    0000200
  108. #define _STANDOUT    A_STANDOUT    /* for compatibility with old curses */
  109. #define    A_UNDERLINE    0000400
  110. #define    A_REVERSE    0001000
  111. #define    A_BLINK        0002000
  112. #define    A_DIM        0004000
  113. #define    A_BOLD        0010000
  114.  
  115. #define    A_ATTRIBUTES    0377600
  116. #define    A_CHARTEXT    0000177
  117.  
  118.  
  119.  
  120. # define        bool    char
  121. # define        reg     register
  122.  
  123. /*
  124.  * chtype is the type used to store a character together with attributes.
  125.  * It can be set to "char" to save space, or "long" to get more attributes.
  126.  */
  127.         typedef unsigned short chtype;
  128.  
  129. struct _win_st {
  130.         short   _cury, _curx;
  131.         short   _maxy, _maxx;
  132.         short   _begy, _begx;
  133.         short   _flags;
  134.         chtype  _attrs;
  135.         bool    _clear;    /* T=clear on every refresh set by clearok() */
  136.         bool    _cls;    /* T=clear on next refresh set by clear() */
  137.         bool    _leave;
  138.         bool    _scroll;
  139.         bool    _use_idl;
  140.         bool    _use_keypad;    /* 0=no, 1=yes, 2=yes/timeout */
  141.         bool    _use_meta;      /* T=use the meta key */
  142.         bool    _nodelay;       /* T=don't wait for tty input */
  143.         chtype  **_y;
  144.         short   *_firstch;
  145.         short   *_lastch;
  146.         short   _tmarg,_bmarg;
  147. };
  148.  
  149. typedef struct _win_st  WINDOW;
  150. extern WINDOW *stdscr, *curscr;
  151.  
  152. /* Funny "characters" enabled for various special function keys for input */
  153. #define KEY_BREAK       0401            /* break key (unreliable) */
  154. #define KEY_DOWN        0402            /* The four arrow keys ... */
  155. #define KEY_UP          0403
  156. #define KEY_LEFT        0404
  157. #define KEY_RIGHT       0405            /* ... */
  158. #define KEY_HOME        0406            /* Home key (upward+left arrow) */
  159. #define KEY_BACKSPACE   0407            /* backspace (unreliable) */
  160. #define KEY_F0          0410            /* Function keys.  Space for 64 */
  161. #define KEY_F(n)        (KEY_F0+(n))    /* keys is reserved. */
  162. #define KEY_DL          0510            /* Delete line */
  163. #define KEY_IL          0511            /* Insert line */
  164. #define KEY_DC          0512            /* Delete character */
  165. #define KEY_IC          0513            /* Insert char or enter insert mode */
  166. #define KEY_EIC         0514            /* Exit insert char mode */
  167. #define KEY_CLEAR       0515            /* Clear screen */
  168. #define KEY_EOS         0516            /* Clear to end of screen */
  169. #define KEY_EOL         0517            /* Clear to end of line */
  170. #define KEY_SF          0520            /* Scroll 1 line forward */
  171. #define KEY_SR          0521            /* Scroll 1 line backwards (reverse) */
  172. #define KEY_NPAGE       0522            /* Next page */
  173. #define KEY_PPAGE       0523            /* Previous page */
  174. #define KEY_STAB        0524            /* Set tab */
  175. #define KEY_CTAB        0525            /* Clear tab */
  176. #define KEY_CATAB       0526            /* Clear all tabs */
  177. #define KEY_ENTER       0527            /* Enter or send (unreliable) */
  178. #define KEY_SRESET      0530            /* soft (partial) reset (unreliable) */
  179. #define KEY_RESET       0531            /* reset or hard reset (unreliable) */
  180. #define KEY_PRINT       0532            /* print or copy */
  181. #define KEY_LL          0533            /* home down or bottom (lower left) */
  182.                                         /* The keypad is arranged like this: */
  183.                                         /*    a1    up    a3   */
  184.                                         /*   left   b2  right  */
  185.                                         /*    c1   down   c3   */
  186. #define KEY_A1          0534            /* upper left of keypad */
  187. #define KEY_A3          0535            /* upper right of keypad */
  188. #define KEY_B2          0536            /* center of keypad */
  189. #define KEY_C1          0537            /* lower left of keypad */
  190. #define KEY_C3          0540            /* lower right of keypad */
  191.  
  192. WINDOW *newwin(), *subwin(), *newpad();
  193.